package com.youthHostel.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.youthHostel.dao.UserDao;
import com.youthHostel.pojo.user;
import com.youthHostel.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private UserDao userDao;
	
	@Override
	public user userLogin(String name, String pass) {
		return userDao.queryUserMes(name, pass);
	}

	@Override
	public PageInfo<user> findAll(int index) {
		PageHelper.startPage(index, 3);
		List<user> list = userDao.findAll();
		return new PageInfo<user>(list);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) {
		return userDao.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(user record) {
		return userDao.insert(record);
	}

	@Override
	public user selectByPrimaryKey(Integer id) {
		return userDao.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKey(user record) {
		return userDao.updateByPrimaryKey(record);
	}

	@Override
	public List<user> findByName(String name, int index) {
		return userDao.findByName(name);
	}

}
